﻿namespace Framework.EncryptionDecryptionService.Attributes
{
    /// <summary>
    /// 不加密特性
    /// <para>使用此特性控制接口加密方式</para>
    /// </summary>
    /// <remarks>
    /// <para>加密方式：控制器加密、API加密</para>
    /// <para>注意：API和控制器加密方式不同时以API的加密方式进行加密</para>
    /// <para>不添加此特性时默认为进行双向加密</para>
    /// </remarks>
    public class NonEncryptedAttribute : Attribute
    {
        /// <summary>
        /// 不加密特性
        /// <para>不加密</para>
        /// </summary>
        public NonEncryptedAttribute()
        {
            encryptionTypes = EncryptionType.None;
        }
        /// <summary>
        /// 不加密特性
        /// <para>设置加密方式</para>
        /// </summary>
        /// <param name="encryptions">加密方式</param>
        public NonEncryptedAttribute(EncryptionType encryptions)
        {
            encryptionTypes = encryptions;
        }

        /// <summary>
        /// 加密方式
        /// </summary>
        private readonly EncryptionType encryptionTypes;
        /// <summary>
        /// 加密方式
        /// </summary>
        public EncryptionType EncryptionTypes
        {
            get { return encryptionTypes; }
        }
    }

    /// <summary>
    /// 加密方式枚举值
    /// </summary>
    public enum EncryptionType
    {
        /// <summary>
        /// 不加密
        /// </summary>
        None = 0,
        /// <summary>
        /// 请求加密
        /// </summary>
        Request = 1,
        /// <summary>
        /// 响应加密
        /// </summary>
        Response = 2,
        /// <summary>
        /// 全加密
        /// </summary>
        Full = 3
    }
}
